const urlParser = document.createElement('a')
import moment from 'moment/moment';
export function domain (url) {
  urlParser.href = url
  return urlParser.hostname
}

export function count (arr) {
  return arr.length
}

export function prettyDate (date) {
  var a = new Date(date)
  return a.toDateString()
}

export function pluralize (time, label) {
  if (time === 1) {
    return time + label
  }

  return time + label + 's'
}
export function notescape(html) {
	if(html){
		return html.toString()
			.replace(html ? /&(?!#?\w+;)/g : /&/g, '&amp;')
			.replace(/&lt;/g, "<")
			.replace(/&gt;/g, ">")
			.replace(/&quot;/g, "\"")
			.replace(/&#39;/g, "\'");
	}
}
export function time(value, formatString){
	formatString = formatString || 'YYYY-MM-DD HH:mm:ss';
	return moment(value).format(formatString);
}
